<template>
  <div class="wrapper">
    <div class="header">
      <div class="title">候选题目列表</div>
      <div class="btns">
        <el-checkbox v-model="displayDesc" size="large"> 显示解析 </el-checkbox>
        <el-button>批量导入习题</el-button>
        <el-button>手动添加习题</el-button>
      </div>
    </div>
    <el-scrollbar class="scroll">
      <QuestionItem
        v-for="(question, index) in questionList"
        :key="index"
        :index="index"
        :id="question.id"
        :content="question.content"
        :options="question.options"
        :answer="question.answer"
        :desc="question.desc"
        :displayDesc="displayDesc"
        :knowledge="question.knowledge"
        :selected="question.selected"
        @add="
          (id) => {
            $emit('add', id)
          }
        "
      />
      <div class="page-wrapper">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="questionList.length"
          class="mt-4"
          style="--el-color-primary: #43b883"
        />
      </div>
    </el-scrollbar>
  </div>
</template>

<script setup>
import QuestionItem from './QuestionItem.vue'
import { ref } from 'vue'

defineProps(['questionList'])

const displayDesc = ref(false)
</script>

<style lang="scss" scoped>
.wrapper {
  height: 100%;
  .header {
    border-bottom: 1px solid #ccc;
    line-height: 50px;
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;

    .title {
      font-size: 20px;
      font-weight: 700;
    }

    .btns {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 1rem;
    }
  }
  .scroll {
    height: calc(100% - 80px);

    .item::after {
      content: '';
      display: inline-block;
      height: 5px;
      width: 100%;
      border-bottom: 1px solid #ddd;
    }

    .page-wrapper {
      display: flex;
      justify-content: center;
      padding-bottom: 40px;
    }
  }
}
</style>
